<template>
  <div class="mr-sh-topData"> 
    <div class="mr-sh-firstbg">
      <el-table
        ref="receiveTable"
        size="mini"
        :data="resData"
        style="width: 100%"
        @selection-change="handleSelectionChange"
        highlight-current-row
      >
      <el-table-column type="selection" width="40"> </el-table-column>
      <el-table-column type="index" label="序号" width="50" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="barcode" label="条码" width="250"  :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="itemName" label="物料名称" width="160" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="itemCode" label="零件图号/成品型号" width="170" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="qualityCode" label="质量编号/成品件号" width="170" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="deliveryQty" label="数量" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="productCode" label="机型" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="batchNo" label="批次" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="startLotNo" label="架次" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="mdsUnit" label="计量单位" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="itemType" label="物料大类" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="empName" label="移交人" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="deliveryDate" label="移交时间" width="130" :show-overflow-tooltip="true"> </el-table-column>
      <el-table-column prop="receiveRemark" label="备注" :show-overflow-tooltip="true"> </el-table-column>
      </el-table>
    </div>
    <!-- 完整功能分页 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNumber"
      :page-sizes="[10,20,50,100]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalCount">
    </el-pagination>
  </div>
</template>
<script>

import { mrMhAll,scanSearch } from "@/utils/api.js";

export default {
  name: "MrShTopData",
  data() {
    return {
      // 当前页数
      pageNumber: 1,
      // 数据总个数
      totalCount: 0,
      // 返回的数据数组
      resData: [],
      // 每页数据个数
      pageSize: 20,
      value: "",
      ss: "",
      multipleSelectionP:[],
      searchData: {
        startTime: "",
        endTime: "",
        tuhao: "",
        qualityNumber: "",
        person:"",
      },
    };
  },
  methods: {
    // 选择每页条数后请求接口更新表格
      handleSizeChange(val) {
        this.pageSize = val
        scanSearch({
        funcType:"handOver",
        pageParameter:{
          rows:this.pageSize,
          page:this.pageNumber
        },
        searchParams:{
          receiveEmpCode:this.searchData.person,
		      qualityCode:this.searchData.qualityNumber
        },
        drawNo:this.searchData.tuhao,
        startTime:this.searchData.startTime,
        endTime:this.searchData.endTime,
      }).then((res)=>{
        this.resData = res.data.responseBody.result
        console.log("扫码移交查询按钮",res)
      })
        // 传pageSize，pageNumber给midSearch
        this.$bus.$emit('shPageNumbers',this.pageSize)
        // console.log(`每页 ${val} 条`);
      },
    // 分页函数
    handleCurrentChange(val) {
      this.pageNumber = val;
        scanSearch({
        funcType:"handOver",
        pageParameter:{
          rows:this.pageSize,
          page:this.pageNumber
        },
        searchParams:{
          receiveEmpCode:this.searchData.person,
		      qualityCode:this.searchData.qualityNumber
        },
        drawNo:this.searchData.tuhao,
        startTime:this.searchData.startTime,
        endTime:this.searchData.endTime,
      }).then((res)=>{
        this.resData = res.data.responseBody.result
        console.log("扫码移交查询按钮",res,this.resData)
      })
    },
    // 勾选函数
    handleSelectionChange(val){
      this.multipleSelection = val
      this.$emit('materialId',this.multipleSelection)
      console.log('勾选',val)
    },
  },
  mounted(){
      // 接收扫码返回的Data
      this.$bus.$on('chuanTableY',(event)=>{
        this.resData = event
        // console.log('shuaxin',event)
      })
      // 接收查询按钮返回的Data,重置数据和总条数和分页所需数据
      this.$bus.$on('scanHandSearchData',(e)=>{
        this.resData = e.resData
        this.totalCount = e.resData.length
        this.searchData.person = e.receiveEmpCode
        this.searchData.qualityNumber = e.qualityCode
        this.searchData.tuhao = e.drawNo
        this.searchData.startTime = e.startTime
        this.searchData.endTime = e.endTime
        // console.log(e)
      })
      
  },
  watch:{
    
  }
};
</script>


<style scoped>
.mr-sh-topData {
  width: 100%;
  height: 100%;
}
.mr-sh-firstbg {
  text-align: center;
}
.el-pagination {
  text-align: center;
}

</style>